package com.guit.hrms.mapper;

import com.guit.hrms.po.otherDept.OtherDept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OtherDeptMapper {
    /**
     * 新增其它部门
     * @param otherDept
     */
    @Insert("insert into " +
            "other_dept(other_dept_number, other_dept_parent_id," +
            "other_dept_name, other_dept_manager_id, other_dept_profile, " +
            "other_dept_level, create_time, update_time)" +
            "VALUES (#{otherDeptNumber},#{otherDeptParentId}," +
            "#{otherDeptName},#{otherDeptManagerId},#{otherDeptProfile}," +
            "#{otherDeptLevel},#{createTime},#{updateTime})")
    void addOtherDept(OtherDept otherDept);

    /**
     * 根据id查询其它部门
     * @param otherDeptId
     * @return
     */
    @Select("select * from other_dept where other_dept_id = #{otherDeptId}")
    OtherDept getOtherDeptById(Integer otherDeptId);

    /**
     * 查询所有其它部门
     * @return 所有其它部门列表
     */
    @Select("select * from other_dept")
    List<OtherDept> getAllOtherDepts();

    /**
     * 更新其它部门
     * @param otherDept
     */
    void updateOtherDept(OtherDept otherDept);

    /**
     * 根据id删除其它部门
     * @param deptId
     */
    @Delete("delete from other_dept where other_dept_id = #{deptId}")
    void deleteOtherDeptById(Integer deptId);

    /**
     * 根据父id删除其它部门
     * @param deptId
     */
    @Delete("delete from other_dept where other_dept_parent_id = #{deptId}")
    void deleteOtherDeptByParentId(Integer deptId);
}
